<template>
  <erp-form-modal-03
    :title="title"
    :field="field"
    :value="value"
    :props="props"
    :extra="extra"
    :options="options"
    :form="form"
    @value-change="handleValueChange"
    @update-id-field="handleUpdateField"
  />
</template>

<script>
import ErpFormModal03 from './ErpFormModal03';
/**
 * 员工选择组件
 * @author maolin
 */
export default {
  name: "ErpFormInvBasStaff",
  components: {
    ErpFormModal03
  },
  props: {
    /**
     * 标题
     * @public
     */
    title: {
      type: String,
      default: '',
    },
    /**
     * 字段
     * @public
     */
    field: {
      type: String,
      default: ''
    },
    /**
     * 值
     * @public
     */
    value: {
      type: [String, Number],
      default: ''
    },
    /**
     * 属性
     * @public
     */
    props: {
      type: Object,
      default () {
        return {
        };
      }
    },
    /**
     * 额外配置
     * ```js
     * return {
          // 表单需要的id字段
          idField: '',
          inputPlaceholder: '',
          modalTitle: '',
          modalWidth: null,
          modalHeight: null,
          // 模态框表格中name对应的字段名
          modalNameField: null,
          // 模态框表格中id对应的字段名
          modalIdField: null,
          // 是否转换为字符串
          needToString: false,
          // 关联额外字段，除了id和name之外还需要关联字段时
          extraData: [
            // {
            //     // 外部id
            //     field: "userId",
            //     // 内部id
            //     relatedField: "id",
            // }
          ]
        }
     * ```
     * @public
     */
    extra: {
      type: Object,
      default () {
        return {
          // 表单需要的id字段
          idField: '',
          inputPlaceholder: '',
          modalTitle: '',
          modalWidth: null,
          modalHeight: null,
          // 模态框表格中name对应的字段名
          modalNameField: null,
          // 模态框表格中id对应的字段名
          modalIdField: null,
          // 是否转换为字符串
          needToString: false,
          modalShow:false,
          // 关联额外字段，除了id和name之外还需要关联字段时
          extraData: [
            // {
            //     // 外部id
            //     field: "userId",
            //     // 内部id
            //     relatedField: "id",
            // }
          ]
        };
      }
    },
    /**
     * 表单对象
     * @public
     */
    form: {
      type: Object,
      default () {
        return {};
      }
    },
    /**
     * 表单配置项
     * @public
     */
    options: {
      type: Object,
      default () {
        return {};
      }
    }
  },
  data() {
    return {}
  },
  /* data() {
    const options = {
      "type": "singleSelect",
      "name": "basStaff",
      "table": {
        "props": {
          "resizable": true
        },
        "permissions": ["basStaff:staffList"],
        "rowKey": "id",
        "list": [
        ],
        "fields": [
          {"label": "员工工号1231231", "width": "100", "fixed": null, "prop": "staffCode", "sortable": "custom"},
          {"label": "员工姓名", "width": "100", "fixed": null, "prop": "name", "sortable": "custom"},
          {"label": "ID卡号", "width": "100", "fixed": null, "prop": "idCard"},
          {"label": "部门", "width": "100", "fixed": null, "prop": "departmentId", "sortable": "custom", "showTextProp": "departmentName"},
          {"label": "职位", "min-width": "100", "width": "", "fixed": null, "prop": "positionId", "sortable": "custom", "showTextProp": "positionName"},
        ],
        "border": false,
        "showPagination": true,
        "showOrderNumber": false,
        "selectable": false,
        "defaultExpandAll": true,
        "showExport": false,
        "customColumn": false,
        "operationWidth": "100"
      },
      "search": {
        "form": {
          "departmentId": null,
          "mobile": null,
          "name": null,
          "staffCode": null,
          "positionId": null,
          "positionName": null,
          "pageOrderBy": null,
          "pageOrderDir": null,
          "pageIndex": 1,
          "pageSize": 30
        },
        "tree": {
          "enable": true,
          "position": "left",
          "key": "departmentId",
          "apiList": {
            "list": {
              "url": "/basStaff/staffListInit",
              "query": {
              },
              "response": "var initDataItems = response.initDataItems; var data = []; for(var i = 0; i < initDataItems.length; i ++) { if(initDataItems[i].name === 'departmentId') {data = initDataItems[i].items; break;} }  return data;"
            }
          },
          "props": {
            "data": [],
            "nodeKey": "id",
            "defaultExpandAll": true,
            "expandOnClickNode": false,
            "highlightCurrent": true,
            "showCheckbox": false,
            "props": {
              "label": "name"
            },
            "treeConfig": {
              "children": "childs"
            }
          }
        },
        "showKeywordQuery": true,
        "headSearchPlaceholder": "请输入名称",
        "showAdvancedQuery": false,
        advancedForm: [
          {
            "type": "hidden",
            "field": "id"
          }
        ]
      },
      "apiList": {
        "dataSourceApi": {
          "url": "/basStaff/staffListInit"
        },
        "list": "/basStaff/staffList"
      },
      "components": {

      },
      "buttons": [
      ]
    };
    return {
      options: options
    };
  }, */
  computed: {},
  watch: {},
  created() {
  },
  mounted() {
  },
  methods: {
    handleValueChange (value) {
      this.$emit('value-change', value);
    },
    handleUpdateField (obj) {
      this.$emit('update-id-field', obj);
    },
  },
};
</script>

<style lang="scss" scoped>

</style>
